package edu.kjxy.day02Synchronized.throwExceptionNoLock;

import edu.kjxy.day02Synchronized.synLockIn_2.Main;

/**
 * 功能:
 * 作者:程序员欧阳子韩
 * 日期:2024/2/1 20:16
 */
public class Service {
    synchronized public void testMethod() {
        if (Thread.currentThread().getName().equals("a")) {
            System.out.println("ThreadName= " + Thread.currentThread().getName()
                    + "run beginTime= " + System.currentTimeMillis());
            int i = 1;
            while (i == 1){
                if (("" + Math.random()).substring(0,8).equals("0.123456")){
                    System.out.println("ThreadName= " + Thread.currentThread().getName()
                                        + " run ExceptionTime = " + System.currentTimeMillis());
                    Integer.parseInt("a");
                }else {
                    System.out.println("Thread B run Time = " + System.currentTimeMillis());
                }
            }
        }
    }
}
